package com.wuad.platformwuad.module.Excel.controller;

import com.wuad.platformwuad.module.Excel.entity.ExcelEasyPoiReadEntity;
import com.wuad.platformwuad.util.ExcelEasyPoiUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * easyPoi 操作excel
 *
 * @author wuad
 * @date 2023年08月10日 14:28
 */
@RestController
public class ExcelEasyPoiController {

    /**
     * 读取Excel数据
     * @param file
     * @return
     */
    @PostMapping(value = "/doImport")
    public void doImport(@RequestParam("file") MultipartFile file) {

        // 解析Excel
        List<ExcelEasyPoiReadEntity> list =  ExcelEasyPoiUtils.importExcel(file,1,1,ExcelEasyPoiReadEntity.class);
        for (int i=0;i<list.size();i++) {
            System.out.println("内容" + list.get(i).toString());
        }

    }

}
